<?php
/* -----------------------------------------------------------------
* 	ID:						$Id: random_products.php 2 2011-02-17 13:35:25Z akausch $
* 	Letzter Stand:			$Revision: 2 $
* 	zuletzt geändert von: 	$Author: akausch $
* 	Datum:					$Date: 2011-02-17 14:35:25 +0100 (Do, 17. Feb 2011) $
*
* 	commerce:SEO by Webdesign Erfurt
* 	http://www.commerce-seo.de
*
* 	Copyright (c) since 2010 commerce:SEO
* ------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* --------------------------------------------------------------- */

$module_smarty = new Smarty;

if ($mobile_template == 'False') {
	$module_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
} else {
	$module_smarty->assign('tpl_path', 'templates/'.CURRENT_MOBILE_TEMPLATE.'/');
}
if(GROUP_CHECK == 'true')
	$group_check = " AND p.group_permission_".$_SESSION['customers_status']['customers_status_id']." = 1 ";

$fsk_lock = '';
if ($_SESSION['customers_status']['customers_fsk18_display'] == '0')
	$fsk_lock = ' and p.products_fsk18!=1';

$random_products_query = "SELECT 
								p.*, 
								pd.products_name, 
								pd.products_short_description, 
								pd.products_description 
							FROM 
								".TABLE_PRODUCTS." p
								LEFT OUTER JOIN ".TABLE_PRODUCTS_DESCRIPTION." pd ON (p.products_id = pd.products_id AND pd.language_id = '".(int) $_SESSION['languages_id']."')
								LEFT OUTER JOIN ".TABLE_PRODUCTS_TO_CATEGORIES." p2c ON (p.products_id = p2c.products_id)
								LEFT OUTER JOIN ".TABLE_CATEGORIES." c ON (p2c.categories_id = c.categories_id)
							WHERE c.categories_status='1'
							AND 
								p.products_status = '1' 
							".$fsk_lock.$group_check."	
							ORDER BY rand() 
							LIMIT ".MAX_RANDOM_PRODUCTS;

$module_content = array ();
$random_products_query = xtDBquery($random_products_query);
$row = 0;
while ($random_products = xtc_db_fetch_array($random_products_query, true)) { $row++;
	$module_content[] = $product->buildDataArray($random_products,'thumbnail','random_products',$row);
}

if (sizeof($module_content) >= 1) {
	$module_smarty->assign('language', $_SESSION['language']);
	$module_smarty->assign('module_content', $module_content);
	$module_smarty->assign('TITLE', RANDOM_PRODUCTS);
	$module_smarty->assign('CLASS', 'random_products');
	// set cache ID
	$module_smarty->caching = 0;
	if ($mobile_template == 'False') {
		$module = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/product_listings.html');
	} else {
		$module = $module_smarty->fetch(CURRENT_MOBILE_TEMPLATE.'/module/product_listings.html');
	}		
	$default_smarty->assign('MODULE_random_products', $module);
}
?>